<%
auth_session = session[:omniauth] || {}
auth_info = auth_session["info"]
%>

<div class="col-12 mb-5">
  <div class="heading text-center mb-4">
    <div class="f1 mb-2"><%= t(".Sign in") %></div>
    <div class="description f6 text-gray-light"><%= t(".Enter your username or email to sign in BlueDoc_html") %></div>
  </div>

  <% if auth_info %>
  <div class="notice my-4">
    <p><%= t(".You have signed in with_html", type: BlueDoc::Utils.omniauth_camelize(auth_session["provider"])) %></p>
    <p><%= t(".Enter your exists BlueDoc account to bind with_html", type: BlueDoc::Utils.omniauth_camelize(auth_session["provider"])) %></p>
  </div>
  <% end %>

  <%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
    <%= render "/shared/error_messages", target: resource %>

    <div class="form-group">
      <%= f.label :email, t(".email"), class: "control-label"  %>
      <%= f.text_field :email, autofocus: true, autocomplete: "email", class: "form-control" %>
    </div>

    <div class="form-group">
      <%= f.label :password, class: "control-label" %>
      <%= f.password_field :password, autocomplete: "current-password", class: "form-control" %>
      <%= link_to t(".forget_password"), new_password_path(resource_name), class: "float-right mt-2 f6 text-gray-light" %>
    </div>

    <% if devise_mapping.rememberable? -%>
      <div class="form-group form-check mt-5">
        <%= f.check_box :remember_me, checked: true %>
        <%= f.label :remember_me, class: "form-check-label" %>
      </div>
    <% end -%>

    <div class="actions">
      <%= f.submit t(".Sign in"), class: "btn btn-primary btn-full" %>
    </div>

    <% if allow_feature?(:ldap_auth) && Setting.ldap_enable? %>
    <div class="pt-3">
      <%= link_to Setting.ldap_title, new_ldap_user_session_path, class: "btn btn-full btn-ldap-auth" %>
    </div>
    <% end %>

    <div class="border-bottom text-center pt-3 pb-5 f6 text-gray-light">
      <%= link_to t(".Didn't receive unlock instructions?"), new_user_unlock_path(resource_name), class: "btn-link btn-link-gray" %>

      <%= link_to t(".Didn't receive confirmation instructions?"), new_confirmation_path(resource_name), class: "btn-link btn-link-gray" %>
    </div>
  <% end %>
</div>

<% if defined? omniauth_authorize_path %>
<div class="col-12">
  <div class="text-center f6 text-gray-light mb-3"><%= t(".Sign in with") %></div>
  <div class="d-flex text-center text-gray">
    <% if Devise.omniauth_configs[:google_oauth2] %>
      <%= link_to icon_tag("google", label: "Google"), omniauth_authorize_path("user", "google_oauth2"), method: :post, class: "" %>
    <% end %>
    <% if Devise.omniauth_configs[:github] %>
      <%= link_to icon_tag("github", label: "GitHub"), omniauth_authorize_path("user", "github"), method: :post, class: "flex-auto" %>
    <% end %>
    <% if Devise.omniauth_configs[:gitlab] %>
      <%= link_to icon_tag("gitlab", label: "GitLab"), omniauth_authorize_path("user", "gitlab"), method: :post, class: "" %>
    <% end %>
  </div>
</div>
<% end %>
